@extends('admin.main')

@section('body')
    <div class="tab-wrap">
        <ul class="tab-nav nav">
            <li>
                <a href="{{urlAdmin('auth','getAccess',['group_name'=>$_GET['group_name'],'group_id'=>$_GET['group_id']])}}">访问授权</a>
            </li>
            <li class="current"><a href="javascript:;">成员授权</a></li>
            <li class="fr">
                <select name="group">
                    @if($authGroup))
                    @foreach($authGroup as $v)
                        <option value="{{urlAdmin('auth','getAdmin',['group_name'=>$v['title'],'group_id'=>$v['id']])}}"
                                @if($v['id'] == $_GET['group_id']) selected @endif >{{$v['title']}}</option>
                    @endforeach
                    @else
                        <option>暂无内容</option>
                    @endif
                </select>
            </li>
        </ul>
        <!-- 数据列表 -->
        <div class="data-table table-striped">
            <table class="">
                <thead>
                <tr>
                    <th class="">ID</th>
                    <th class="">昵称</th>
                    <th class="">最后登录时间</th>
                    <th class="">最后登录IP</th>
                    <th class="">状态</th>
                    <th class="">操作</th>
                </tr>
                </thead>
                <tbody>
                @if(count($rows['data']))
                    @foreach($rows['data'] as $v)
                        <tr>
                            <td>{{$v['aid']}} </td>
                            <td>{{$v['admin']['nickname']}}</td>
                            <td><span>{{$v['admin']['last_login_time'] ? date('Y-m-d H:i:s',$v['admin']['last_login_time']) : ''}}</span></td>
                            <td><span>{{$v['admin']['last_login_ip'] ? $v['admin']['last_login_ip'] : ''}}</span></td>
                            <td>{{$v['admin'] ? num_to_text($v['admin']['status']) : ''}}</td>
                            <td><a href="{{urlAdmin('auth','getRemoveFromGroup',['aid'=>$v['aid'],'group_id'=>$v['group_id']])}}"
                                   class="ajax-get">解除授权</a>
                            </td>
                        </tr>
                    @endforeach
                @else
                    <td colspan="6" class="text-center"></td>
                @endif
                </tbody>
            </table>


        </div>
        <div class="main-title">
            <div class="page fl">
                @if($rows['last_page']>1)
                    <div>
                        <a class="first" href="{{urlAdmin('auth','getAdmin',['page'=>1,'group_name'=>request('group_name'),'group_id'=>request('group_id')])}}">首页</a>
                        @if($rows['prev_page_url'])
                            <a class="prev" href="{{$rows['prev_page_url']}}&group_name={{request('group_name')}}&group_id={{request('group_id')}}">&lt;&lt;</a>
                        @endif
                        @if(count($rows['pageNoList']))
                            @foreach($rows['pageNoList'] as $v)
                                @if($rows['current_page'] == $v)
                                    <span class="current">{{$v}}</span>
                                @else
                                    <a class="num" href="{{urlAdmin('auth','getAdmin',['page'=>$v,'group_name'=>request('group_name'),'group_id'=>request('group_id')])}}">{{$v}}</a>
                                @endif
                            @endforeach
                        @endif
                        @if($rows['next_page_url'])
                            <a class="next" href="{{$rows['next_page_url']}}&group_name={{request('group_name')}}&group_id={{request('group_id')}}">&gt;&gt;</a>
                        @endif
                        <a class="last" href="{{urlAdmin('auth','getAdmin',['page'=>$rows['last_page'],'group_name'=>request('group_name'),'group_id'=>request('group_id')])}}">末页</a>
                        <span class="rows">共 {{$rows['total']}} 条记录</span>
                    </div>
                @endif
            </div>
            <div id="add-to-group" class="tools fr">
                <form class="add-user" action="{{urlAdmin('auth','postAddToGroup')}}" method="post"
                      enctype="application/x-www-form-urlencoded">
                    <input class="text input-4x" type="text" name="aid" placeholder="请输入管理员id,多个用英文逗号分隔">
                    <input type="hidden" name="group_id" value="{{$_GET['group_id']}}">
                    <button type="submit" class="btn ajax-post" target-form="add-user">新 增</button>
                </form>
            </div>
        </div>

    </div>
@endsection

@section('script')
    <script type="text/javascript" charset="utf-8">
        $('select[name=group]').change(function () {
            location.href = this.value;
        });
    </script>
@endsection
